package com.ruoyi.web.controller.operationAdministration;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.github.pagehelper.PageHelper;
import com.ruoyi.operationAdministration.vo.EquOperationMaintenanceManageVo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.operationAdministration.domain.EquOperationMaintenanceManage;
import com.ruoyi.operationAdministration.service.IEquOperationMaintenanceManageService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 设备运维管理Controller
 *
 * @author lth
 * @date 2023-12-21
 */
@RestController
@RequestMapping("/operationAdministration/manage")
public class EquOperationMaintenanceManageController extends BaseController
{
    @Autowired
    private IEquOperationMaintenanceManageService equOperationMaintenanceManageService;

    /**
     * 查询设备运维管理列表
     */
    @PreAuthorize("@ss.hasPermi('operationAdministration:manage:list')")
    @GetMapping("/list")
    public TableDataInfo list(EquOperationMaintenanceManage equOperationMaintenanceManage)
    {
        startPage();
        List<EquOperationMaintenanceManage> list = equOperationMaintenanceManageService.selectEquOperationMaintenanceManageList(equOperationMaintenanceManage);
        return getDataTable(list);
    }

    /**
     * 导出设备运维管理列表
     */
    @PreAuthorize("@ss.hasPermi('operationAdministration:manage:export')")
    @Log(title = "设备运维管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EquOperationMaintenanceManage equOperationMaintenanceManage)
    {
        List<EquOperationMaintenanceManage> list = equOperationMaintenanceManageService.selectEquOperationMaintenanceManageList(equOperationMaintenanceManage);
        ExcelUtil<EquOperationMaintenanceManage> util = new ExcelUtil<EquOperationMaintenanceManage>(EquOperationMaintenanceManage.class);
        util.exportExcel(response, list, "设备运维管理数据");
    }

    /**
     * 获取设备运维管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('operationAdministration:manage:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(equOperationMaintenanceManageService.selectEquOperationMaintenanceManageById(id));
    }

    /**
     * 新增设备运维管理
     */
    @PreAuthorize("@ss.hasPermi('operationAdministration:manage:add')")
    @Log(title = "设备运维管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EquOperationMaintenanceManage equOperationMaintenanceManage)
    {
        return toAjax(equOperationMaintenanceManageService.insertEquOperationMaintenanceManage(equOperationMaintenanceManage));
    }

    /**
     * 修改设备运维管理
     */
    @PreAuthorize("@ss.hasPermi('operationAdministration:manage:edit')")
    @Log(title = "设备运维管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EquOperationMaintenanceManage equOperationMaintenanceManage)
    {
        return toAjax(equOperationMaintenanceManageService.updateEquOperationMaintenanceManage(equOperationMaintenanceManage));
    }

    /**
     * 删除设备运维管理
     */
    @PreAuthorize("@ss.hasPermi('operationAdministration:manage:remove')")
    @Log(title = "设备运维管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(equOperationMaintenanceManageService.deleteEquOperationMaintenanceManageByIds(ids));
    }


    /**
     *      运维管理列表
     */
    @PreAuthorize("@ss.hasPermi('operationAdministration:manage:list')")
    @GetMapping("/listByVo")
    public TableDataInfo listByVo(@RequestBody EquOperationMaintenanceManageVo vo)
    {
        PageHelper.startPage(vo.getPageNum(),vo.getPageSize());
        List<EquOperationMaintenanceManage> list = equOperationMaintenanceManageService.listByVo(vo);
        return getDataTable(list);
    }

}
